package com.example.web.service;

import com.example.web.pojo.ProcessUserVo;
import com.linsy.product.redis.mq.entity.MqDataEntity;
import com.linsy.product.redis.mq.service.Broker;
import com.linsy.product.redis.mq.service.SendMsgDecorator;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

@Component
public class TestSend extends SendMsgDecorator<ProcessUserVo> {

    public TestSend(Broker broker) {
        // 第二个参数为消费主题
        super(broker, "TEST");
    }

    /**
     * 发送消息之前
     */
    @Override
    public void beforeSend(List<MqDataEntity> entityList) {
        // 可以把entityList存储数据库起来
        System.out.println("发送之前");
    }

    /**
     * 发送消息之后
     */
    @Override
    public void afterSend(List<MqDataEntity> entityList) {
        System.out.println("发送之后");
    }

    /**
     * 转换成队列List
     */
    @Override
    public List<Object> convert(ProcessUserVo s) {
        return Collections.singletonList(s);
    }

}
